--[套装属性]
local tz_data = {}
for _,info in ipairs(load_excel('存档数据.xlsx','套装属性')) do
    local lv = info['T级']
    if not tz_data[lv] then
        tz_data[lv] = {}
    end
    
    info.tip = ('%0.f件：%s'):format(info['件数'],format_obj(info,info['属性']))
    info.attrs = cd_unpack_attrs(info['属性'],'data')

    table.insert(tz_data[lv],info)
end

--套装介绍
function get_cdtz_tip(name)
    local list = ac.player.self:get_data('存档套装计数') or {}
    local data = tz_data[name] or {}
    local num = list[name] or 0
    local tips = {}
    for a,info in ipairs(data) do
        if num>=info['件数'] then
            tips[a] = ('|cff00ff00%s|r'):format(info.tip)
        else
            tips[a] = ('|cff999999%s|r'):format(info.tip)
        end
    end
    return ('%s套装(%s/6)|n%s'):format(name,num,table.concat(tips,'|n'))
end

ac.game:event '玩家-刷新套装介绍'(function(_,player)
    local data = player:get_data('存档装备-携带')
    local list = {}
    for key,item in pairs(data) do
        local name = item['前缀']
        if list[name]==nil then
            list[name] = 0
        end
        list[name] = list[name] + 1
    end
    player:set_data('存档套装计数',list)
end)

ac.game:event '玩家-加载套装属性'(function(_,player,hero)
    player:notify('玩家-刷新套装介绍',player)

    local list = ac.player.self:get_data('存档套装计数') or {}
    for name,num in pairs(list) do
        local data = tz_data[name] or {}
        for a=#data,1,-1 do
            local info = data[a]
            if num>=info['件数'] then
                load_cdsx(hero,info,'attrs')
                break
            end
        end
    end
end)




--[词条数据]
local entry = {}
local xxs = {
    ['★'] = 1,
    ['★★'] = 2,
    ['★★★'] = 3,
}
for _,info in ipairs(load_excel('存档数据.xlsx','词条')) do
    local xx = info['星级']
    local lv = xxs[xx]
    if not entry[lv] then
        entry[lv] = {}
    end
    info.tip = format_obj(info, info['效果'])
    table.insert(entry[lv],info)
end


--词条内容
function get_cdct_tip(info)
    local affix = {}
    local tips = {}
    local abis = info.abi or {}
    for a,abi in ipairs(abis) do
        local xx = math.floor(abi/1000)
        local id = abi%1000
        local abi = entry[xx][id]
        affix[a] = abi
        tips[a] = ('|cffff9900%s%s:|r|n%s'):format(abi['星级'],abi['名称'],abi.tip)
    end

    info.abi_list = affix
    if #tips>0 then
        info.abi_tip = table.concat(tips,'|n|n')
    end
end

ac.game:event '玩家-加载词条属性'(function(_,player,hero)
    local data = player:get_data('存档装备-携带') or {}
    for key,item in pairs(data) do
        local abi = item.abi_list or {}
        for _,name in ipairs(abi) do

        end
    end
end)
